// 模板综合案例，实现类似于vector的MyArray
#include <iostream>
#include <string>
#include "MyArray.hpp"
#include "person2.hpp"
using namespace std;

// 测试构造函数、拷贝构造函数、析构函数、=重载
void test1()
{
    MyArray<int> a1(20);
    cout << "a1大小: " << a1.getSize() << endl;
    cout << "a1容量: " << a1.getCapacity() << endl;
    MyArray<int> a2(30);
    cout << "a2大小: " << a2.getSize() << endl;
    cout << "a2容量: " << a2.getCapacity() << endl;
    a1 = a2;
    cout << "a1大小: " << a1.getSize() << endl;
    cout << "a1容量: " << a1.getCapacity() << endl;
    MyArray<int> a3(a1);
    cout << "a3大小: " << a3.getSize() << endl;
    cout << "a3容量: " << a3.getCapacity() << endl;
}
void print(MyArray<Person2<string, int>> &arr)
{
    for (int i = 0; i < arr.getSize(); ++i)
    {
        arr[i].show();
    }
    
}
// 测试尾插、尾删自定义数据类型
void test2()
{
    Person2<string, int> p1("lxy", 20);
    Person2<string, int> p2("a", 40);
    Person2<string, int> p3("b", 60);
    Person2<string, int> p4("c", 80);
    MyArray<Person2<string, int>> arr1(3);
    arr1.push_back(p1);
    arr1.push_back(p2);
    arr1.push_back(p3);
    arr1.push_back(p4);
    arr1.pop_back();
    print(arr1);
}
int main(void)
{
    // test1();
    test2();

    return 0;
}